package cn.edu.njpi.回溯.老鼠走迷宫;

/**
 * @author 朱宗辉
 * @version V1.0
 * @Package cn.edu.njpi.回溯.老鼠走迷宫
 * @date 2021/7/30 17:01
 */
public class TraceRecord {
    public Node first;
    public Node last;

    public boolean isEmpty() {
        return first == null;
    }

    public void insert(int x, int y) {
        Node newNode = new Node(x, y);
        if (this.isEmpty()) {
            first = newNode;
            last = newNode;
        } else {
            last.next = newNode;
            last = newNode;
        }
    }

    public void delete() {
        Node newNode;
        if (this.isEmpty()) {
            System.out.println("队列为空");
            return;
        }
        newNode = first;
        while (newNode.next != last) {
            newNode = newNode.next;
        }
        newNode.next = last.next;
        last = newNode;
    }
}

class Node {
    int x;
    int y;
    Node next;

    public Node(int x, int y) {
        this.x = x;
        this.y = y;
        this.next = null;
    }
}
